package dao;

import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class QueryPlaceName {

    public static int getResult(String name) {
        MyConnection myCon = new MyConnection();
        myCon.getConnection();
        int n = 0;
        try {
            PreparedStatement ps;

            ps = myCon.connection.prepareStatement(
                    "SELECT count(*) FROM place where PlacePosition=?");
            ps.setString(1, name);
            ResultSet rs = ps.executeQuery();
            while (rs.next()) {
                n = rs.getInt(1);
            }
            ps.close();

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            myCon.closeConnection();
        }
        return n;
    }
}
